package com.workerhelping.controller;

import com.workerhelping.po.Admin;
import com.workerhelping.result.Result;
import com.workerhelping.result.ResultCodeEnum;
import com.workerhelping.service.AdminService;
import com.workerhelping.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    AdminService adminService;

    @PostMapping("/login")
    public Result<Object> adminLogin(@RequestBody Admin admin) {
        try {
            boolean isExist = adminService.getAdminByName(admin);
            if (isExist)
                return Result.ok();
            else return Result.fail();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail();
        }
    }
}